package com.glory.huaweipda.base

import android.app.Application
import android.content.Context
import android.os.Handler
import com.glory.mvvmnet.utils.InitUtils
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_SharePreferencesUtils

/**
 * @author HX
 * @date 2021/5/21
 * @desc
 */
class MyApp: Application() {

    override fun onCreate() {
        super.onCreate()
        InitUtils.init(this)
        app = applicationContext
        Constant.mainUrl = FreeApi_SharePreferencesUtils.getSharePre("SystemSet", "sercerUrl", Constant.mainUrl,applicationContext)
        Constant.REQUEST_URL_DEBUG = FreeApi_SharePreferencesUtils.getSharePre("SystemSet", "REQUEST_URL_DEBUG", "http://" + Constant.mainUrl + "/PDA/",applicationContext)
        val sharePre = FreeApi_SharePreferencesUtils.getSharePre(
            "SystemSet",
            "connectTimeout",
            applicationContext
        )

        if (!sharePre.equals("")){
            val s = sharePre + "000"
            Constant.connectTimeout =s.toInt()
        }

    }
    var handler: Handler? = null

    companion object {
        var instance: MyApp? = null
            get() {
                if (field == null) {
                    field = MyApp()
                }
                return field
            }
            private set

        @JvmField
        var app: Context? = null
    }

}